package com.lehecai.core.api.event;

import com.lehecai.core.YesNoStatus;
import com.lehecai.core.api.AbstractApiResultBean;
import com.lehecai.core.lottery.LotteryType;
import com.lehecai.core.util.CoreDateUtils;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created by JSH on 2015/3/4.
 */
public class BigPrizeSummary extends AbstractApiResultBean {

    public static final String QUERY_ID = "id";
    public static final String QUERY_CREATE_AT = "create_at";
    public static final String QUERY_PRIZE_TIME = "timeline";
    public static final String QUERY_IS_TOP = "is_top";
    public static final String QUERY_TITLE = "title";
    public static final String QUERY_LOTTERY_TYPE = "lottery_type";

    public static final String SET_ID = "id";
    public static final String SET_TITLE = "title";//稿件标题
    public static final String SET_LINK = "link";//稿件链接
    public static final String SET_PRIZE_POSTTAX = "prize_posttax";//税前奖金
    public static final String SET_LOTTERY_TYPE = "lottery_type";//中奖彩种
    public static final String SET_TYPE = "type";//彩种分类
    public static final String SET_TIME_LINE = "timeline";//中奖时间
    public static final String SET_IS_TOP = "is_top";//是否置顶
    public static final String SET_INFO = "info";//内容描述
    public static final String SET_IMG_SRC = "img_src";//活动图片
    public static final String SET_STATUS = "status";//显示状态

    public static final String ORDER_CREATE_AT = "create_at";
    public static final String OEDER_UPDATE_AT = "update_at";

    private Integer id;
    private Date createAt;
    private Date timeline;
    private YesNoStatus isTop;
    private String title;
    private LotteryType lotteryType;
    private String link;
    private String prizePosttax;
    private String info;
    private String imgSrc;
    private YesNoStatus status;
    private Date updateAt;
    private SelectLotteryType type;

    public static BigPrizeSummary convertFromJSONObject(JSONObject object) {
        if (object == null) {
            return null;
        }
        BigPrizeSummary topPrizeSummary = new BigPrizeSummary();
        topPrizeSummary.id = getInt(object, "id");
        topPrizeSummary.createAt = CoreDateUtils.parseDate(getString(object, "create_at"), CoreDateUtils.DATETIME);
        topPrizeSummary.timeline = CoreDateUtils.parseDate(getString(object, "timeline"), CoreDateUtils.DATETIME);
        topPrizeSummary.isTop = YesNoStatus.getItem(getInt(object, "is_top"));
        topPrizeSummary.title = getString(object, "title");
        topPrizeSummary.lotteryType = LotteryType.getItem(getInt(object, "lottery_type"));
        topPrizeSummary.link = getString(object, "link");
        topPrizeSummary.prizePosttax = getString(object, "prize_posttax");
        topPrizeSummary.info = getString(object, "info");
        topPrizeSummary.imgSrc = getString(object, "img_src");
        topPrizeSummary.status = YesNoStatus.getItem(getInt(object, "status"));
        topPrizeSummary.updateAt = CoreDateUtils.parseDate(getString(object, "update_at"), CoreDateUtils.DATETIME);
        topPrizeSummary.type = SelectLotteryType.getItem(getInt(object, "type"));
        return topPrizeSummary;
    }

    public static List<BigPrizeSummary> convertFromJSONArray(JSONArray array) {
        if (array == null) {
            return null;
        }
        List<BigPrizeSummary> list = new ArrayList<BigPrizeSummary>();
        for (Object o : array) {
            JSONObject object = (JSONObject) o;
            list.add(convertFromJSONObject(object));
        }
        return list;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getCreateAt() {
        return createAt;
    }

    public void setCreateAt(Date createAt) {
        this.createAt = createAt;
    }

    public Date getTimeline() {
        return timeline;
    }

    public void setTimeline(Date timeline) {
        this.timeline = timeline;
    }

    public YesNoStatus getIsTop() {
        return isTop;
    }

    public void setIsTop(YesNoStatus isTop) {
        this.isTop = isTop;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public LotteryType getLotteryType() {
        return lotteryType;
    }

    public void setLotteryType(LotteryType lotteryType) {
        this.lotteryType = lotteryType;
    }

    public String getLink() {
        return link;
    }

    public void setLink(String link) {
        this.link = link;
    }

    public String getPrizePosttax() {
        return prizePosttax;
    }

    public void setPrizePosttax(String prizePosttax) {
        this.prizePosttax = prizePosttax;
    }

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }

    public String getImgSrc() {
        return imgSrc;
    }

    public void setImgSrc(String imgSrc) {
        this.imgSrc = imgSrc;
    }

    public YesNoStatus getStatus() {
        return status;
    }

    public void setStatus(YesNoStatus status) {
        this.status = status;
    }

    public Date getUpdateAt() {
        return updateAt;
    }

    public void setUpdateAt(Date updateAt) {
        this.updateAt = updateAt;
    }

    public SelectLotteryType getType() {
        return type;
    }

    public void setType(SelectLotteryType type) {
        this.type = type;
    }
}
